<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.Calendar" %>
<%@ page import="com.google.appengine.api.users.User" %>
<%@ page import="com.google.appengine.api.users.UserService" %>
<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>
<%@ page import="javax.jdo.PersistenceManager" %>
<%@ page import="javax.jdo.Query" %>
<%@ page import="com.gestordeavisos.Historial" %>
<%@ page import="com.gestordeavisos.PMF" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>

 <% 
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    if (user == null) {
    	response.sendRedirect("/gestordeavisos.jsp");
    }
	else
	{%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Historial de Avisos</title>
</head>
<body><% 
	PersistenceManager pm = PMF.get().getPersistenceManager();
	String select_query = "select from " + Historial.class.getName(); 
	Query query = pm.newQuery(select_query); 
	query.setFilter("autor == paramAutor"); 
	query.declareParameters("java.lang.String paramAutor"); 
	List<Historial> historiales = (List<Historial>) query.execute(user);
	if(historiales.isEmpty()){
%>	<table> Historial de Avisos
		<tbody>
		<tr><th>Hora planeada</th><th>Hora efectuada</th></tr></tbody></table>
<%	}else{%>

<table> Historial de Avisos
<tbody>
<tr><th>Hora planeada</th><th>Hora efectuada</th></tr>

<% 	for(int i=0;i<historiales.size();i++){
%>
<tr><td><%=historiales.get(i).getActividad()+" "+historiales.get(i).getCuando()+" "+historiales.get(i).getFecha()%></td>
<td><%=historiales.get(i).getActividad()+" "+historiales.get(i).getCuandoreal()+" "+historiales.get(i).getFechareal()%></td></tr>	

<%	}
	}
	}
%>
</tbody>
</table>
<input type="button" value="Volver" onclick = "window.location.href='gestordeavisos.jsp'"></input>
</body>
</html>
